import { createRouter, createWebHistory } from 'vue-router';
import layout from '@/views/index';

export const routerList = [
  {
    name: 'Main',
    path: '/main',
    meta: {
      name: '应用',
      icon: 'ios-checkmark',
      needLogin: true
    },
    redirect: '/home',
    component: layout,
    children: [
      {
        name: 'home',
        path: '/home',
        meta: {
          name: '首页',
          icon: 'md-apps'
        },
        component: () => import('@/views/home')
      },
      {
        name: 'book',
        path: '/book',
        meta: {
          name: '图书信息',
          icon: 'md-apps'
        },
        component: () => import('@/views/book/book')
      },
      {
        name: 'type',
        path: '/type',
        meta: {
          name: '类型信息',
          icon: 'md-apps'
        },
        component: () => import('@/views/type/type')
      },
      {
        name: 'user',
        path: '/user',
        meta: {
          name: '用户信息',
          icon: 'md-apps'
        },
        component: () => import('@/views/user/user')
      },
      {
        name: 'history',
        path: '/history',
        meta: {
          name: '历史信息',
          icon: 'md-apps'
        },
        component: () => import('@/views/history/history')
      },
      {
        name: 'personal',
        path: '/personal',
        meta: {
          name: '个人信息',
          icon: 'md-apps'
        },
        component: () => import('@/views/personal/personal')
      }
    ]
  },
  {
    name: 'login',
    path: '/',
    meta: {
      name: '登陆'
    },
    component: () => import('@/views/login')
  },
  {
    name: 'noLogin',
    path: '/noLogin',
    component: () => import('@/views/error/noLogin')
  }
];

export default createRouter({
  history: createWebHistory(),
  routes: [...routerList]
});
